package com.webdiy.dfss.action;

import com.sys.plat.util.HttpUtil;
import com.sys.plat.web.core.ActionContext;
import com.sys.plat.web.core.BaseAction;
import com.sys.system.Constants;
import com.sys.tool.MailTool;
import com.webdiy.dao.model.DfssUserInfo;
import com.webdiy.dfss.form.UserForm;
import com.webdiy.dfss.iface.PlanService;
import com.webdiy.dfss.iface.UserService;
import com.webdiy.dfss.impl.PlanServiceImpl;
import com.webdiy.dfss.impl.UserServiceImpl;

/**
 * Created by IntelliJ IDEA.
 * User: mabo
 * Date: 2009-11-25
 * Time: 15:59:24
 * To change this template use File | Settings | File Templates.
 */
public class UserAction extends BaseAction{

    private UserService getService() {
        return (UserService) getService("UserServiceImpl");
    }

    private UserForm getForm() {
        return (UserForm) ActionContext.getForm();
    }


    public String login() {
        DfssUserInfo userInfo = getService().login(getForm().getU().getUserCode(), getForm().getU().getUserPassWord());
        if (userInfo != null) {
            ActionContext.getRequest().getSession().setAttribute("dfssUserInfo", userInfo);
            HttpUtil.sessionRmvAttr("xyxx");
            log.warn("登录成功");
            return "login_ok";
        }
        HttpUtil.reqSetAttr("u", getForm().getU());
        return "login";
    }


    public String showUserList() {
        return "";
    }

    public String addUser() {
        HttpUtil.reqSetAttr("u", getForm().getU());
        return EDIT;
    }

    public String editUser() {
        return EDIT;
    }

    public String updateUser() {
        getService().saveUser(getForm().getU());

        return "login";
    }


}
